from equantum import QuantumCircuit

circ = QuantumCircuit(4)
circ.x(3)

for i in range(4):
    circ.h(i)

# 量子黑盒模拟函数
def Uf(inputlist):
    x, y = inputlist[0], inputlist[1]
    outputlist = []
    def f(x):
        if (x == 0 or x == 2 or x == 4 or x == 6):
            return 0
        return 1
    outputlist.append(x)
    outputlist.append(f(x)^y)
    return outputlist

# 在线路中调用量子黑盒
circ.oracle(Uf, [0, 1, 2], [3]) # 输入模拟函数、函数的输入

for i in range(3):
    circ.h(i)

circ.measure([0, 1, 2])


